<extend name="Base/base" />
<block name="button">
	<a href="{:U('?type=export')}" class="btn btn-primary"><i class="fa fa-plus"></i> {:L('text_add')}</a>
	<button class="btn btn-danger" data-toggle="btn-delete" confirm="{:L('warning_delete_title')}" confirm-info="{:L('warning_delete_text')}" type="submit" form="form"><i class="fa fa-trash"></i> {:L('text_delete')}</button>
</block>
<block name="body">
	<div class="main" id="main">
		<div id="top-alert" class="fixed alert alert-danger" style="display: none;">
            <button class="close fixed" style="margin-top: 4px;">&times;</button>
            <div class="alert-content"></div>
        </div>
	</div>
	<div class="panel panel-default">
		<div class="panel-heading">
			<h3><i class="fa fa-list"></i>  {$heading_title}</h3>
		</div>
		<div class="panel-body">
			<form method="post" action="{:U('del')}" enctype="multipart/form-data" id="form">
				<table class="table table-bordered table-hover">
					<thead>
						<tr>
						<th style="width:50px;"><input type="checkbox" data-toggle="js-checked-all"></th>
						<th>{:L('column_name')}</th>
						<th>{:L('column_volume')}</th>
						<th>{:L('column_compress')}</th>
						<th>{:L('column_size')}</th>
						<th>{:L('column_date')}</th>
						<th>{:L('text_status')}</th>
						<th class="text-right">{:L('text_action')}</th>
						</tr>
					</thead>
					<tbody>
						<foreach name="list" item="item">
						<tr>
							<td><input type="checkbox" name="selected[]" value="{$item.time}"></td>
							<td>{$item.time|date='Ymd-His',###}</td>
							<td>{$item.part}</td>
							<td>{$item.compress}</td>
							<td>{$item.size|format_bytes}</td>
							<td>{$key}</td>
							<td>-</td>
							<td class="text-right">
								<a data-toggle="tooltip" title="{:L('button_import')}" href="{:U('import?time='.$item['time'])}" class="btn btn-primary db-import"><i class="fa fa-retweet"></i></a>
							</td>
						</tr>
						</foreach>
					</tbody>
				</table>
			</form>
		</div>
		<div class="panel-footer">
			<nav>
				<ul class="pagination">
				
				</ul>
			</nav>
		</div>
	</div>
</block>
<block name="script">
    <script type="text/javascript">
        $(".db-import").click(function(){
            var self = this, status = ".";
            $.get(self.href, success, "json");
            window.onbeforeunload = function(){ return "{:L('text_do_not_close')}" }
            return false;
        
            function success(data){
                if(data.status){
                    if(data.gz){
                        data.info += status;
                        if(status.length === 5){
                            status = ".";
                        } else {
                            status += ".";
                        }
                    }
                    $(self).parent().prev().text(data.info);
                    if(data.part){
                        $.get(self.href, 
                            {"part" : data.part, "start" : data.start}, 
                            success, 
                            "json"
                        );
                    }  else {
                        window.onbeforeunload = function(){ return null; }
                    }
                } else {
                    updateAlert(data.info,'alert-danger');
                }
            }
        });
    </script>
</block>